package org.gten.gegedexin.service.user.token;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import org.gten.gegedexin.service.user.common.User;
import org.springframework.data.redis.core.RedisTemplate;

import javax.annotation.Resource;

public class JwtToken {
    @Resource
    private RedisTemplate<String,Object> redisTemplate;

    private static final Integer TIME_DATE = 30;
    private static final String SECRET_KEY = "Emiya";

    public static String createToken(User user){
        Algorithm algorithm = Algorithm.HMAC256(SECRET_KEY);
        String Token = JWT.create()
                .withClaim("account",user.getAccount())
                .withClaim("password",user.getPassword())
                .withClaim("name",user.getName())
                .sign(algorithm);
        return Token;
    }

}
